# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer:
pkgname=libcorkipset
pkgver=1.1.1
_debver=20150311-8
pkgrel=0
pkgdesc="Small C helper library for storing sets of IPv4 and IPv6 addresses"
url="https://github.com/rogers0/libcorkipset"
arch="all"
license="BSD-3-Clause"
makedepends="cmake check-dev libcork-dev"
checkdepends="python3"
subpackages="$pkgname-dev"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/rogers0/$pkgname/archive/debian/$pkgver+$_debver.tar.gz
	"

builddir="$srcdir/$pkgname-debian-$pkgver-$_debver"

prepare() {
	default_prepare
	mkdir build

	for p in debian/patches/*.patch; do
		patch -p1 -i "$p"
	done

	sed -e 's%#include <ipset%#include <libcorkipset%' \
		-e 's%#include "ipset%#include "libcorkipset%' \
		-i include/ipset/*.h */*/*/*.c */*/*/*.c.in */*/*.c */*.c
	mv include/ipset include/libcorkipset
}

build() {
	cd build
	cmake .. \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_BUILD_STYLE=Release
	make
}

check() {
	cd build
	make test
}

package() {
	cd build
	make DESTDIR="$pkgdir" install
}

sha512sums="5bbce2727da1665e734981959ecb253b4052d8cc6c426fded7e1678b6e2505bc9f4c0ab3cd3b6a03f834f5e20bd1d670cc19f7491fe0ad5b7cb772e7309f5009  libcorkipset-1.1.1.tar.gz"
